﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DMS.Base;
using System.Data;

namespace DMS.Web
{
    public partial class sql : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnExecute_Click(object sender, EventArgs e)
        {
            try
            {
                txtMessage.Text = "";
                gvResult.DataSource = null;
                gvResult.DataBind();

                DBHelper.Instance.ExecuteNonQuery(CommandType.Text, txtSql.Text);

                txtMessage.Text = "ok";
            }
            catch (Exception ex)
            {
                txtMessage.Text = ex.Message;
            }
        }

        protected void btnSelect_Click(object sender, EventArgs e)
        {
            try
            {
                txtMessage.Text = "";
                gvResult.DataSource = null;
                gvResult.DataBind();

                DataSet ds = DBHelper.Instance.ExecuteDataSet(CommandType.Text, txtSql.Text);
                gvResult.DataSource = ds;
                gvResult.DataBind();

                txtMessage.Text = "ok";
            }
            catch (Exception ex)
            {
                txtMessage.Text = ex.Message;
            }
        }
    }
}